package com.study.spark.scala.chapter07

object Scala13_Collection_Method_1{
  def main(args: Array[String]): Unit = {
    // TODO 集合 - 方法 - 滑动 - 滚动
    val list = List(1, 2, 3, 4, 5, 6)

    // 滑动
    val iterator: Iterator[List[Int]] = list.sliding(3, 2)
    while (iterator.hasNext) {
      val ints: List[Int] = iterator.next()
      println(ints)
      /*
      List(1, 2, 3)
      List(3, 4, 5)
      List(5, 6)
       */
    }

    // 滚动： 滑动时没有重复数据
    val iterator1: Iterator[List[Int]] = list.sliding(3, 3)
    while (iterator1.hasNext) {
      val ints: List[Int] = iterator1.next()
      println(ints)
      /*
      List(1, 2, 3)
      List(4, 5, 6)
       */
    }
  }
}
